home *** CD-ROM | disk | FTP | other *** search
- /* Copyright (C) 1982, 1988, 1989 Walter Tichy
- Distributed under license by the Free Software Foundation, Inc.
-
- This file is part of RCS.
-
- RCS is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
- any later version.
-
- RCS is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with RCS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
- Report problems and direct all questions to:
-
- rcs-bugs@cs.purdue.edu
-
- Although there's not much point for THIS file, as it is a rough translation
- of rcsfreeze.sh from Bourne shell script to C, by Nikki Locke.
- (nikki@cix.compulink.co.uk or nikki@compulink.co.uk if that fails)
-
- */
-
- #ifndef lint
- static char rcsid[]=
- "$Header: d:/rcs/rcs/rcsfreez.c 1.1 91/02/07 14:09:15 ROOT_DOS Exp $";
- #endif
- /*****************************************************************************
- * 'rcsfreeze' has the purpose of assigning a symbolic revision
- * number to a set of RCS files, which form a valid configuration.
- *
- * The idea is to run rcsfreeze each time a new version is checked
- * in. A unique symbolic revision number (C_[number], where number
- * is increased each time rcsfreeze is run) is then assigned to the most
- * recent revision of each RCS file of the main trunk.
- *
- * If the command is invoked with an argument, then this
- * argument is used as the symbolic name to freeze a configuration.
- * The unique identifier is still generated
- * and is listed in the log file but it will not appear as
- * part of the symbolic revision name in the actual RCS file.
- *
- * A log message is requested from the user which is saved for future
- * references.
- *
- * The program works only on all RCS files at one time.
- * It is important that all changed files are checked in (there are
- * no precautions against any error in this respect).
- * file names:
- * rcsfreeze/version for the version number
- * rscfreeze/log for the log messages, most recent
- * logmessage first.
- * N.B. Under Unix, the file names are RCS/rcsfreeze.version and
- * RCS/rcsfreeze.log, but these are too long for DOS. The DOS
- * files have been placed in their own directory so that the afn
- * "RCS/*.*" still refers only to RCS source files
- *****************************************************************************
- */
-
-
- /* $Log: rcsfreez.c $
- * Revision 1.1 91/02/07 14:09:15 ROOT_DOS
- * Initial revision
- *
- */
-
- #include <stdio.h>
- #include <string.h>
- #include <direct.h>
-
- char *PROGNAME;
- int VERSIONNUMBER;
- char SYMREV[64], SYMREVNAME[64];
- FILE *fd, *fd2;
- char inpline[256], filename[128], revision[128];
- #define VERSIONFILE "rcsfreez/version"
- #define LOGFILE "rcsfreez/log"
- #define TEMPFILE "rcsfreez.tmp"
-
- main(int argc,char **argv)
- {
- mkdir("rcsfreez");
- PROGNAME = strrchr(argv[0],'\\');
- if(!PROGNAME)
- PROGNAME = strrchr(argv[0],':');
- if(PROGNAME)
- PROGNAME++;
- else
- PROGNAME = argv[0];
- /*
- * Get version no from rcsfreez.ver, and increment
- */
- fd = fopen(VERSIONFILE,"r");
- if(fd)
- {
- fscanf(fd,"%d",&VERSIONNUMBER);
- fclose(fd);
- }
- VERSIONNUMBER++;
- fd = fopen(VERSIONFILE,"w");
- fprintf(fd,"%d\n",VERSIONNUMBER);
- fclose(fd);
- sprintf(SYMREV,"C_%d",VERSIONNUMBER);
- if(argc > 1)
- strcpy(SYMREVNAME,argv[1]);
- else
- strcpy(SYMREVNAME,SYMREV);
- printf("%s: symbolic revision number computed: \"%s\"\n",PROGNAME,SYMREV);
- printf("%s: symbolic revision number used: \"%s\"\n",PROGNAME,SYMREVNAME);
- printf("%s: the two differ only when %s invoked with argument\n",PROGNAME,PROGNAME);
- /*
- * Stamp the logfile. Because we order the logfile the most recent
- * first we will have to save everything right now in a temporary file.
- */
- fd = fopen(TEMPFILE,"w");
- fprintf(fd,"Version: %s(%s)\n",SYMREVNAME,SYMREV);
- fprintf(fd,"-----------\n");
- /*
- * Now ask for a log message, continously add to the log file
- */
- printf("%s: give log message, summarizing changes\n",PROGNAME);
- printf(" (terminate with ^Z or single '.')\n");
- printf(">> ");
- fflush(stdout);
- while(gets(inpline) && inpline[0] != 26 && strcmp(inpline,"."))
- {
- fprintf(fd,"%s\n",inpline);
- printf(">> ");
- fflush(stdout);
- }
- fprintf(fd,"-----------\n\n");
- fd2 = fopen(LOGFILE,"r");
- if(fd2)
- {
- while(fgets(inpline,256,fd2))
- fputs(inpline,fd);
- fclose(fd2);
- }
- fclose(fd);
- /*
- * combine old and new logfiles
- */
- fd = fopen(LOGFILE,"w");
- fd2 = fopen(TEMPFILE,"r");
- while(fgets(inpline,256,fd2))
- fputs(inpline,fd);
- fclose(fd2);
- fclose(fd);
- unlink(TEMPFILE);
- /*
- * Now the real work begins by assigning a symbolic revision number
- * to each rcs file. Take the most recent version of the main trunk.
- */
- system("rlog -h rcs/*.* >" TEMPFILE);
- fd = fopen(TEMPFILE,"r");
- if(!fd)
- {
- fprintf(stderr,"rlog error\n");
- exit(1);
- }
- while(fgets(inpline,256,fd))
- {
- if(!strncmp(inpline,"RCS file:",9))
- {
- char *s = strrchr(inpline,' ');
-
- filename[0] = 0;
- if(s)
- sscanf(s,"%s",filename);
- }
- else if(filename[0] && !strncmp(inpline,"head:",5))
- {
- char *s = strchr(inpline,' ');
-
- if(s)
- {
- sscanf(s,"%s",revision);
- printf("%s: file name: \"%s\", Revision Number: %s\n",
- PROGNAME,filename,revision);
- sprintf(inpline,"rcs -q -n%s:%s %s",SYMREVNAME,revision,filename);
- system(inpline);
- }
- filename[0] = 0;
- }
- }
- fclose(fd);
- unlink(TEMPFILE);
- return 0;
- }
-
-